{
  "properties" : { },
  "id" : "04343c9f854345b2bb42cec815c7736e",
  "script" : null,
  "groupId" : "23234bfccdc54495a21a41d64ab0ed00",
  "name" : "获取模板历史数据",
  "createTime" : 1727070862504,
  "updateTime" : 1726649060140,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "getHistoryValue",
  "method" : "GET",
  "parameters" : [ {
    "name" : "name",
    "value" : "addressForward",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }, {
    "name" : "deviceId",
    "value" : "D3761420980988602955",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": []\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
import cn.hutool.core.util.StrUtil;
import org.springframework.jdbc.core.JdbcTemplate;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang.StringEscapeUtils;
import com.alibaba.fastjson.JSONArray;
import org.springblade.core.tool.utils.CollectionUtil;
import log
import com.kd.ndmp.config.MagicConfig
import com.zaxxer.hikari.HikariDataSource;
import com.kd.ndmp.core.entity.DynamicModelEntity;
import cn.hutool.core.util.StrUtil;

HikariDataSource dataSource = new HikariDataSource()

dataSource.setJdbcUrl("jdbc:dm://192.100.5.20:5236/SHAANXI?compatibleMode=oracle")
dataSource.setUsername("SHAANXI")
dataSource.setPassword("Admin@9000")
dataSource.setDriverClassName("dm.jdbc.driver.DmDriver")

flag = true
if (!name.startsWith("HISTORY_")) {
    tableName = "HISTORY_" + StrUtil.toUnderlineCase(name).toUpperCase()
}

sql = " select count(1) from SHAANXI." + tableName

try {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource)
    map = jdbcTemplate.queryForList(sql);
} catch (e) {
    log.error("不存在，当前表" + tableName)
    log.error(e.getMessage())
    flag = false
}

if (!flag) {
    return null;
}

List record = new ArrayList();
if (StringUtils.isEmpty(time) && tableName.contains("USAGE_RATE")) {
    record = db.select(""" select data from ${tableName} where device_id = #{deviceId}
        <if test="startTime != null">
            AND time >= #{startTime}
        </if>
        <if test="endTime != null">
            AND time <= #{endTime}
        </if>
        ORDER BY time desc
        limit 100 """)
} else {
    id = deviceId
    sql1 = """ select data from ${tableName} where device_id = #{id} 
                <if test="time != null and time != ''">
                    AND TO_TIMESTAMP(time,'YYYY-MM-DD')=TO_TIMESTAMP(#{time},'YYYY-MM-DD')
                </if>
                ORDER BY time desc limit 1 
            """
    record = db.select(sql1)
}
List result = new ArrayList();
record.forEach(data -> {
    str = StringEscapeUtils.unescapeJava(data);
    List modelEntityList = JSONArray.parseArray(str, DynamicModelEntity.class);
    if (modelEntityList != null){
        result.add(modelEntityList);
    }
});

if (CollectionUtil.isEmpty(result)) {
    return []
} else {
    return result
}